package com.angrybutterfly.cheminsdelamemoire;

import java.io.IOException;
import java.util.List;
import java.util.Locale;

import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;

public class MapFragment extends SupportMapFragment {
	GoogleMap map;

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		map = getMap();
		List<Address> la;
		try {
			la = new Geocoder(getActivity(), Locale.getDefault()).getFromLocationName(
					MainActivity.selectedTown, 1);
		} catch (IOException e) {
			la = null;
			e.printStackTrace();
		}
		LatLng ll = new LatLng(la.get(0).getLatitude(), la.get(0)
				.getLongitude());
		map.moveCamera(CameraUpdateFactory.newLatLngZoom(ll, 15));

		map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
		map.setMyLocationEnabled(true);
	}
}
